home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
001-025
/
disk_001
/
balls
/
bres.c
< prev
next >
Wrap
Text File
|
1992-05-06
|
754b
|
40 lines
/*
** b r e s . c
**
** perry s. kivolowitz - ihnp4!ptsfa!well!perry
**
** not to be distritbuted for commercial use. any distribution
** must included this notice, please.
**
** generate radial displacements according to bresenham's circle
** algorithm. suitable for running twice, giving a fast spherical
** surface.
**
*/
bres(r , array)
register short *array;
register r;
{
register x , y , d;
x = 0;
y = r;
d = 3 - 2 * r;
while (x < y) {
*(array + r - y) = x;
*(array + r - x) = y;
*(array + r + y - 1) = x;
*(array + r + x - 1) = y;
if (d < 0) d += 4 * x + 6;
else d += 4 * (x - y--) + 10;
x++;
}
if (x == y) {
*(array + r - y) = x;
*(array + r + y - 1) = x;
}
}